package conqueror.com.systemupdate.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import conqueror.com.systemupdate.R;
import conqueror.com.systemupdate.bean.LocalBean;


public class LocalListViewAdapter extends BaseAdapter {
    private List<LocalBean> mList;
    private Context mContext;

    public LocalListViewAdapter(Context context, List list) {
        this.mContext = context;
        this.mList = list;
    }

    @Override
    public int getCount() {
        return mList == null ? 0 : mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList == null ? null : mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = View.inflate(mContext, R.layout.local_item, null);
            holder = new ViewHolder();
            holder.mTvFileName = (TextView) view.findViewById(R.id.tv_localItem);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        LocalBean localBean = mList.get(i);
        holder.mTvFileName.setText(localBean.fileName);
        notifyDataSetChanged();
        return view;
    }

    private class ViewHolder {
        TextView mTvFileName;
        ImageView mImageView;
    }
}
